#include "buzzer.h"


void buzzer_init(void)
{
    GpioInit();
    // 蜂鸣器引脚 设置为 PWM功能
    IoSetFunc(WIFI_IOT_IO_NAME_GPIO_8, WIFI_IOT_IO_FUNC_GPIO_8_PWM1_OUT);
    PwmInit(WIFI_IOT_PWM_PORT_PWM1);
    hi_pwm_set_clock(PWM_CLK_XTAL);
    PwmStop(WIFI_IOT_PWM_PORT_PWM1);
}

void buzzer_on_normal(void)
{
    PwmStart(WIFI_IOT_PWM_PORT_PWM1, 10*1000, 20*1000);//50%
}

void buzzer_on_low1(void)
{
    PwmStart(WIFI_IOT_PWM_PORT_PWM1, 2*1000, 20*1000);//10%
}

void buzzer_on_low2(void)
{
    PwmStart(WIFI_IOT_PWM_PORT_PWM1, 1*1000, 20*1000);//1%
}

void buzzer_off(void)
{
    PwmStop(WIFI_IOT_PWM_PORT_PWM1);
}